
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_ADRESSE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[EBAS_ADRESSE]
GO

CREATE TABLE [dbo].[EBAS_ADRESSE] (
	[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
	[ATTENTION] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NOT NULL ,
	[GADE] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NOT NULL ,
	[POST_NR_GUID] [uniqueidentifier] NOT NULL ,
	[TELEFON] [varchar] (50) COLLATE Danish_Norwegian_CI_AS NOT NULL ,
	[TELEFAX] [varchar] (50) COLLATE Danish_Norwegian_CI_AS NULL ,
	[E_MAIL] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL ,
	[EJER_GUID] [uniqueidentifier] NOT NULL ,
	[ADRESSE_TYPE_GUID] [uniqueidentifier] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[EBAS_ADRESSE] WITH NOCHECK ADD 
	CONSTRAINT [DF_EBAS_ADRESSE_ATTENTION] DEFAULT ('') FOR [ATTENTION],
	CONSTRAINT [PK_ADRESSE] PRIMARY KEY  CLUSTERED 
	(
		[GUID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[EBAS_ADRESSE] ADD 
	CONSTRAINT [FK_EBAS_ADRESSE_EBAS_ADRESSE_TYPE] FOREIGN KEY 
	(
		[ADRESSE_TYPE_GUID]
	) REFERENCES [dbo].[EBAS_ADRESSE_TYPE] (
		[GUID]
	),
/*
	CONSTRAINT [FK_EBAS_ADRESSE_EBAS_STUDERENDE] FOREIGN KEY 
	(
		[EJER_GUID]
	) REFERENCES [dbo].[EBAS_STUDERENDE] (
		[GUID]
	),
	CONSTRAINT [FK_EBAS_ADRESSE_EBAS_EJERFORHOLD] FOREIGN KEY 
	(
		[EJER_GUID]
	) REFERENCES [dbo].[EBAS_EJERFORHOLD] (
		[GUID]
	),
*/	
	CONSTRAINT [FK_EBAS_ADRESSE_EBAS_POST_NR] FOREIGN KEY 
	(
		[POST_NR_GUID]
	) REFERENCES [dbo].[EBAS_POST_NR] (
		[GUID]
	)	
GO


